#include "CheckBox.h"
#include "Tooltip.h"

CheckBox::CheckBox()
: m_pTooltip(NULL)
{
	m_hf = CreateFont(15, 0, 0, 0, FW_NORMAL, FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, "Arial");
}
CheckBox::~CheckBox()
{
	if(m_pTooltip)
	{
		delete m_pTooltip;
		m_pTooltip = NULL;
	}
}
bool CheckBox::Setup(HWND a_hWnd, HINSTANCE a_hInst, int a_xPos, int a_yPos, int a_width, int a_height, char* a_pLabel, char* a_pTooltip)
{
	m_hWnd = CreateWindowEx(NULL, "Button", "", WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_CHECKBOX | BS_AUTOCHECKBOX, a_xPos, a_yPos, a_width, a_height, a_hWnd, NULL, a_hInst, NULL);
	if(m_hWnd == NULL)
	{
		return false;
	}
	m_pTooltip = new Tooltip();
	m_pTooltip->CreateTooltip(m_hWnd, a_pTooltip);

	SetWindowText(m_hWnd, a_pLabel);

	SendMessage(m_hWnd, WM_SETFONT, (WPARAM)m_hf, (LPARAM)true);	
	
	UpdateWindow(m_hWnd);
	ShowWindow(m_hWnd, SW_SHOW);

	return true;
}
bool CheckBox::IsChecked()
{
	return SendMessage(m_hWnd, BM_GETCHECK, 0, 0) == BST_CHECKED ? true : false;
}